package com.chinacoal.microservice.controller;

import com.chinacoal.microservice.HouseTypeManagementClient;
import com.chinacoal.microservice.pojo.CcmsSmartleasingHouseType;
import com.chinacoal.microservice.service.HouseTypeManagementService;
import com.chinacoal.microservice.util.PassToken;
import com.chinacoal.microservice.util.QueryCriteria;
import com.chinacoal.microservice.util.Result;
import com.chinacoal.microservice.util.UserLoginToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhuliang
 * @version V1.0
 * @Description: 房源管理-户型管理-后端控制类
 * @date 2020-11-11 11：24
 */
@RestController
public class HouseTypeManagementController implements HouseTypeManagementClient {

    @Autowired
    private HouseTypeManagementService houseTypeManagementService;

    /**
     * @Description: 查询所有的户型信息（带分页）
     * @author zhuliang
     * @date 2020/11/11 11:24
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingHouseType>> getAllTypes(QueryCriteria queryCriteria, String token) {
        return houseTypeManagementService.getAllTypes(queryCriteria, token);
    }

    /**
     * @Description: 根据户型id查询对应的户型信息
     * @author zhuliang
     * @date 2020/11/11 11:57
     */
    @Override
    @UserLoginToken
    public Result<CcmsSmartleasingHouseType> getTypeById(String pkHouseTypeId, String token) {
        return houseTypeManagementService.getTypeById(pkHouseTypeId, token);
    }

    /**
     * @Description: 添加户型信息
     * @author zhuliang
     * @date 2020/11/11 13:45
     */
    @Override
    @UserLoginToken
    public Result addHouseType(CcmsSmartleasingHouseType houseType, String token) {
        return houseTypeManagementService.addHouseType(houseType, token);
    }

    /**
     * @Description: 修改户型信息
     * @author zhuliang
     * @date 2020/11/11 13:57
     */
    @Override
    @UserLoginToken
    public Result updateHouseType(CcmsSmartleasingHouseType houseType, String token) {
        return houseTypeManagementService.updateHouseType(houseType, token);
    }

    /**
     * @Description: 根据户型id批量删除户型信息
     * @author zhuliang
     * @date 2020/11/11 14:02
     */
    @Override
    @UserLoginToken
    public Result deleteHouseType(String deleteId,  String token) {
        return houseTypeManagementService.deleteHouseType(deleteId, token);
    }

    /**
     * @Description: 条件查询（带分页）
     * @author zhuliang
     * @date 2020/11/11 14:39
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingHouseType>> getConditionQuery(QueryCriteria queryCriteria, String token) {
        return houseTypeManagementService.getConditionQuery(queryCriteria, token);
    }

    /**
     * @Description: 根据楼宇id查询户型信息
     * @author zhuliang
     * @date 2020/11/12 17:27
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingHouseType>> getHouseTypeByBuildingId(String fkBuildingId, String token) {
        return houseTypeManagementService.getHouseTypeByBuildingId(fkBuildingId, token);
    }
}
